<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>新建功能权限</title>
<%@include file="../collect/meta.jsp"%>
<link rel="stylesheet" href="css/radius.css" type="text/css"></link>
<link rel="stylesheet" href="css/Inputstyle.css" type="text/css"></link>
<link rel="stylesheet" href="css/mshop.css" type="text/css"></link>
<script type="text/javascript" src="${ctx}/js/returnTop.js"></script>
</head>
<body lang="zh-cn">
	<div class="wrapper">
		<c:import url="/collect/top.jsp"></c:import>
		<div class="main-container" id="main-container">
			<div class="main-container-inner">
				<c:import url="/collect/left.jsp"></c:import>
				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<ul class="breadcrumb">
							<li><i class="icon-home home-icon"></i><a href="functionaction!watchAllFunction">功能权限</a></li>
							<li>新建功能权限</li>
						</ul>
						<!-- .breadcrumb -->
					</div>
					<div class="page-content">
						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
								<form action="functionaction!addFunction" name="addFunction" method="post">
									<div align="center">
										<div class="common">
											<label for="one">功能名称:&nbsp;</label> <input type="text"
												class="input" id="one" name="function.name" />
											<div id="content" class="cont"></div>
										</div>
										<div class="shopclass" style="margin-left:5px;">
											<label>功能级别:&nbsp;</label>
											<label>
												<input type="radio" name="function.level"
													value="2" checked="checked">通用
											</label>
											<label>
												<input  type="radio" name="function.level" value="0">超级管理员</label>
											<label>
												<input type="radio" name="function.level" value="1">商户
											</label>
										</div>
										<div class="common">
											<label for="two">功能描述:&nbsp;</label>
											<input type="text" class="input" id="two" name="function.discription" />
										</div>
										<div id="btn-team">
											<input type="button" class="btn btn-primary radius"
												id="but" value="添加" />
											<a class="btn btn-primary radius" href="functionaction!watchAllFunction">返回</a>
										</div>
									</div>
								</form>
								<!-- PAGE CONTENT ENDS -->
							</div>
							<!-- /.col -->
						</div>
						<!-- /.row -->
					</div>
					<!-- /.page-content -->
				</div>
				<!-- /.main-content -->
			</div>
			<!-- /.main-container-inner -->
			<a href="#" id="btn-scroll-up"
				class="btn-scroll-up btn btn-sm btn-inverse"
				style="position:fixed;bottom:0;"> <i
				class="icon-double-angle-up icon-only bigger-110"></i> </a>
		</div>
		<!-- /.main-container -->
		<div class="push"></div>
	</div>
	<c:import url="/collect/down.jsp"></c:import>

	<script type="text/javascript">
		$(document)
			.ready(
				function() {
					var nu = /\s/;
					var str = /[\ |\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?]/;
					$("#but")
						.click(
							function() {
								var one = $("#one").val();
								if (one.length == 0) {
									alert("请填写功能名称!");
									return false;
								}
								if (nu.test(one)) {
									alert("功能名称中有空格!");
									return false;
								}
								if (str.test(one)) {
									alert("名称中含有非法字符!");
									return false;
								}
										
								var two = $("#two").val();
								if (str.test(two)) {
									alert("描述中含有非法字符!");
									return false;
								}
										
								$.ajax({
									url : "functionaction!verifyFunctionName",
									type: "post",
									data : {
										"functionName" : one
									},
									datatype : "json",
									success : function(data) {
										var map = jQuery.parseJSON(data);
										if (map.temp == 'ok') {
											$("form[name='addFunction']").submit();
										} else if(map.temp == 'wrong'){
											alert("功能名称重复！");
										} else{
											alert("系统异常！");
										}
									},
									error : function(request) {
										alert("Connection error");
									}
								});
						});
				});
		//防dropmenu刷新收回
		$(document).ready(function() {
			$('.gongneng > a').css("color","red");
		});
	</script>
</body>
</html>